package com.kmxd.ams.core.common.enums;

import com.kmxd.ams.core.common.constant.ErrorCode;
import com.kmxd.ams.core.exception.BizException;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 流程相关枚举
 *
 * @author ZuoLG
 */
@Getter
@AllArgsConstructor
public enum FlowEnum {
  /** 利用流程 */
  FLOW_USE("flow_use", "利用流程"),

  FLOW_USE_ENTITY("flow_entity_use", "实体利用流程"),

  /** 档案室接收档案流程 */
  FLOW_RECEIVE_ARCHIVES("flow_receive_archives", "档案室接收档案流程"),
  /** 档案退回业务部门流程 */
  FLOW_RETURN_BUSINESS("flow_return_business", "档案退回业务部门流程"),
  /** 跨单位利用申请流程 */
  FLOW_USING_APPLY("flow_using_apply", "跨单位利用申请流程"),
  /** 跨单位利用提供流程 */
  FLOW_USING_PROVIDE("flow_using_provide", "跨单位利用提供流程"),
  /** 复制申请流程 */
  FLOW_COPY_APPLY("flow_copy_apply", "复制申请流程"),
  /** 鉴定申请流程 */
  FLOW_GUIDE_APPLY("flow_guide_apply", "鉴定申请流程"),
  /** 跨全宗移交档案流程 */
  FLOW_FONDS_ARCHIVES_HANDOVER("flow_fonds_archives_handover", "跨全宗移交档案流程"),
  /** 跨全宗接收档案流程 */
  FLOW_FONDS_ARCHIVES_RECEIVING("flow_fonds_archives_receiving", "跨全宗接收档案流程"),
  /** 档案入库流程 */
  FLOW_IN_IN_ARCH("flow_in_in_arch", "档案入库流程"),
  /** 档案出库流程 */
  FLOW_IN_OUT_ARCH("flow_in_out_arch", "档案出库流程"),
  /** 档案编研发布流程 */
  FLOW_ARCH_PUBLISH("flow_arch_publish", "档案编研发布流程"),
  /** 档案编研取消流程 */
  FLOW_ARCH_CANCEL("flow_arch_cancel", "档案编研取消流程");

  private String key;
  private String title;

  public static FlowEnum convert(String key) {
    return Arrays.stream(values())
        .filter(x -> x.key.equals(key))
        .findAny()
        .orElseThrow(() -> BizException.instance(ErrorCode.NOT_FOUND, "未找到指定流程：" + key));
  }
}
